﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using NetDon.OA.Interface;
using NetDon.Utilities;
using NetDon.OA.Business;


namespace NetDon.OA.Portal
{
    public partial class MyHome : PageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                var service = ServiceContainer.GetService<ISecurityService>();
                var collection = service.GetPermitModules(CurrentApplicationContext.UserId);
                if (collection.Count > 0)
                {
                    Response.Redirect(collection.First().Functions[0].NavigateUrl);
                    return;
                }
                throw new Exception("请给此用户分配权限!");
                //BindBirthdayReminders();
                //BindWorkflow();
                //BindMyCalendar();
                //BindNotice();
                //BindMyApply();

            }
        }
        private void BindWorkflow()
        {


        }
        private void BindMyCalendar()
        {

        
        }
        private void BindBirthdayReminders()
        {

        }

        private void BindNotice()
        {
          
         

        }

        private void BindMyApply()
        {
           
        }



        protected void lnkMoreNews_Click(object sender, EventArgs e)
        {
            Response.Redirect(SiteUrls.MyWork.MyCalendarManagement);
        }

        protected void lnkMoreBirthdayReminders_Click(object sender, EventArgs e)
        {
            Response.Redirect(SiteUrls.HRMS.EmployeeBirthday);
        }
        protected void lnkMoreNeedMyApprovalReminders_Click(object sender, EventArgs e)
        {
            Response.Redirect("~/Workflow/NeedApprove.aspx");
        }

        protected void lnkNoticeMore_Click(object sender, EventArgs e)
        {
            Response.Redirect("~/MyWork/NoticeManage.aspx");
        }

        protected void lnkMyApplyMore_Click(object sender, EventArgs e)
        {
            Response.Redirect("~/Workflow/MyApply.aspx");
        }

        protected void repNeedMyApprovalReminders_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {

           
        }

        protected void repNotice_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType !=
ListItemType.AlternatingItem)
                return;
            else
            {
                HiddenField hiddenNoticeId = (HiddenField)e.Item.FindControl("NoticeId");
                LinkButton btnNoticeDetail = (LinkButton)e.Item.FindControl("lnkTitle");
                btnNoticeDetail.OnClientClick = string.Format("showNoticeDetailEx('{0}');return false;", hiddenNoticeId.Value);
            }
        }

        protected void repMyApply_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
          
               
           

        }

        protected void repBirthdayReminders_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType !=
      ListItemType.AlternatingItem)
                return;
            else
            {
                //HiddenField hiddenUserId = (HiddenField)e.Item.FindControl("UserId");
                //LinkButton btnWorkDetail = (LinkButton)e.Item.FindControl("lnkTransferFiles");
                //LinkButton btnLinkButton1 = (LinkButton)e.Item.FindControl("LinkButton1");
                //btnWorkDetail.OnClientClick = string.Format("viewUserEx('{0}');return false;", hiddenUserId.Value);
                //btnLinkButton1.OnClientClick = string.Format("viewUserEx('{0}');return false;", hiddenUserId.Value);
            }

        }

        //OnClientClick="viewWorkDetailsEx('<%#Eval("WorkflowApplyId") %>','<%#Eval("FlowCategoryId") %>','<%#Eval("FlowId") %>');return false;"
        //OnClientClick="viewUserEx('<%#Eval("UserId") %>');return false;"
    }
}